package com.lcz.licence.config;

import com.lcz.licence.entity.LicenseVerifyParam;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author lcz
 * @desc 许可证自动配置
 * @mail lcz_0130@163.com
 * @date 2025/07/23
 */

@Configuration
@EnableConfigurationProperties(LicenseVerifyParam.class)
@ConditionalOnClass(LicenseCheckInterceptor.class)
public class LicenseAutoConfiguration {

    @Bean()
    @ConditionalOnMissingBean
    public InterceptorConfig interceptorConfig() {
        return new InterceptorConfig();
    }

    @Bean()
    @ConditionalOnMissingBean
    public LicenseCheckInterceptor licenseCheckInterceptor() {
        return new LicenseCheckInterceptor();
    }

    @Bean()
    @ConditionalOnMissingBean
    public LicenseCheckListener licenseCheckListener() {
        return new LicenseCheckListener();
    }

    @Bean
    public static LicenseVerifyParam licenseProperties() {
        return new LicenseVerifyParam();
    }
}

